package c.a.a;

import android.animation.Animator.AnimatorListener;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable.Callback;
import android.os.Build.VERSION;
import android.view.View;
import android.widget.ImageView.ScaleType;
import c.a.a.d0.r;
import com.pgl.sys.ces.out.ISdkLite;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;

/* compiled from: LottieDrawable */
public class l extends Drawable implements Callback, Animatable {
    public final Matrix a = new Matrix();
    public f b;
    public final c.a.a.e0.d c;
    public float d;
    public boolean e;
    public boolean f;
    public final ArrayList<o> g;
    public final AnimatorUpdateListener h;
    public ScaleType i;
    public c.a.a.a0.b j;
    public String k;
    public b l;
    public c.a.a.a0.a m;
    public boolean n;
    public c.a.a.b0.l.c o;
    public int p;
    public boolean q;
    public boolean r;
    public boolean s;
    public boolean t;

    /* compiled from: LottieDrawable */
    public class f implements AnimatorUpdateListener {
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            l lVar = l.this;
            c.a.a.b0.l.c cVar = lVar.o;
            if (cVar != null) {
                cVar.q(lVar.c.d());
            }
        }
    }

    /* compiled from: LottieDrawable */
    public interface o {
        void a(f fVar);
    }

    /* compiled from: LottieDrawable */
    public class a implements o {
        public final /* synthetic */ String a;

        public a(String str) {
            this.a = str;
        }

        public void a(f fVar) {
            l.this.q(this.a);
        }
    }

    /* compiled from: LottieDrawable */
    public class b implements o {
        public final /* synthetic */ int a;
        public final /* synthetic */ int b;

        public b(int i, int i2) {
            this.a = i;
            this.b = i2;
        }

        public void a(f fVar) {
            l.this.p(this.a, this.b);
        }
    }

    /* compiled from: LottieDrawable */
    public class c implements o {
        public final /* synthetic */ int a;

        public c(int i) {
            this.a = i;
        }

        public void a(f fVar) {
            l.this.l(this.a);
        }
    }

    /* compiled from: LottieDrawable */
    public class d implements o {
        public final /* synthetic */ float a;

        public d(float f) {
            this.a = f;
        }

        public void a(f fVar) {
            l.this.u(this.a);
        }
    }

    /* compiled from: LottieDrawable */
    public class e implements o {
        public final /* synthetic */ c.a.a.b0.e a;
        public final /* synthetic */ Object b;
        public final /* synthetic */ c.a.a.f0.c c;

        public e(c.a.a.b0.e eVar, Object obj, c.a.a.f0.c cVar) {
            this.a = eVar;
            this.b = obj;
            this.c = cVar;
        }

        public void a(f fVar) {
            l.this.a(this.a, this.b, this.c);
        }
    }

    /* compiled from: LottieDrawable */
    public class g implements o {
        public void a(f fVar) {
            l.this.j();
        }
    }

    /* compiled from: LottieDrawable */
    public class h implements o {
        public void a(f fVar) {
            l.this.k();
        }
    }

    /* compiled from: LottieDrawable */
    public class i implements o {
        public final /* synthetic */ int a;

        public i(int i) {
            this.a = i;
        }

        public void a(f fVar) {
            l.this.r(this.a);
        }
    }

    /* compiled from: LottieDrawable */
    public class j implements o {
        public final /* synthetic */ float a;

        public j(float f) {
            this.a = f;
        }

        public void a(f fVar) {
            l.this.t(this.a);
        }
    }

    /* compiled from: LottieDrawable */
    public class k implements o {
        public final /* synthetic */ int a;

        public k(int i) {
            this.a = i;
        }

        public void a(f fVar) {
            l.this.m(this.a);
        }
    }

    /* compiled from: LottieDrawable */
    public class l implements o {
        public final /* synthetic */ float a;

        public l(float f) {
            this.a = f;
        }

        public void a(f fVar) {
            l.this.o(this.a);
        }
    }

    /* compiled from: LottieDrawable */
    public class m implements o {
        public final /* synthetic */ String a;

        public m(String str) {
            this.a = str;
        }

        public void a(f fVar) {
            l.this.s(this.a);
        }
    }

    /* compiled from: LottieDrawable */
    public class n implements o {
        public final /* synthetic */ String a;

        public n(String str) {
            this.a = str;
        }

        public void a(f fVar) {
            l.this.n(this.a);
        }
    }

    static {
        Class cls = l.class;
    }

    public l() {
        c.a.a.e0.d dVar = new c.a.a.e0.d();
        this.c = dVar;
        this.d = 1.0f;
        this.e = true;
        this.f = false;
        HashSet hashSet = new HashSet();
        this.g = new ArrayList();
        f fVar = new f();
        this.h = fVar;
        this.p = ISdkLite.REGION_UNSET;
        this.s = true;
        this.t = false;
        dVar.a.add(fVar);
    }

    public <T> void a(c.a.a.b0.e eVar, T t, c.a.a.f0.c<T> cVar) {
        c.a.a.b0.l.c cVar2 = this.o;
        if (cVar2 == null) {
            this.g.add(new e(eVar, t, cVar));
            return;
        }
        int i = 1;
        if (eVar == c.a.a.b0.e.c) {
            cVar2.i(t, cVar);
        } else {
            c.a.a.b0.f fVar = eVar.b;
            if (fVar != null) {
                fVar.i(t, cVar);
            } else {
                List emptyList;
                int i2 = 0;
                if (cVar2 == null) {
                    c.a.a.e0.c.b("Cannot resolve KeyPath. Composition is not set yet.");
                    emptyList = Collections.emptyList();
                } else {
                    ArrayList arrayList = new ArrayList();
                    this.o.f(eVar, 0, arrayList, new c.a.a.b0.e(new String[0]));
                    emptyList = arrayList;
                }
                while (i2 < emptyList.size()) {
                    ((c.a.a.b0.e) emptyList.get(i2)).b.i(t, cVar);
                    i2++;
                }
                i = 1 ^ emptyList.isEmpty();
            }
        }
        if (i != 0) {
            invalidateSelf();
            if (t == q.A) {
                u(g());
            }
        }
    }

    public final void b() {
        f fVar = this.b;
        f fVar2 = fVar;
        c.a.a.d0.h0.c.a aVar = r.a;
        Rect rect = fVar.j;
        List emptyList = Collections.emptyList();
        c.a.a.b0.l.e.a aVar2 = c.a.a.b0.l.e.a.PRE_COMP;
        List emptyList2 = Collections.emptyList();
        c.a.a.b0.j.l lVar = r16;
        c.a.a.b0.j.l lVar2 = new c.a.a.b0.j.l(null, null, null, null, null, null, null, null, null);
        c.a.a.b0.l.e eVar = r2;
        int i = 0;
        c.a.a.b0.l.e eVar2 = new c.a.a.b0.l.e(emptyList, fVar2, "__container", -1, aVar2, -1, null, emptyList2, lVar, 0, i, 0, 0.0f, 0.0f, rect.width(), rect.height(), null, null, Collections.emptyList(), c.a.a.b0.l.e.b.NONE, null, false);
        fVar = this.b;
        this.o = new c.a.a.b0.l.c(this, eVar, fVar.i, fVar);
    }

    public void c() {
        c.a.a.e0.d dVar = this.c;
        if (dVar.k) {
            dVar.cancel();
        }
        this.b = null;
        this.o = null;
        this.j = null;
        c.a.a.e0.d dVar2 = this.c;
        dVar2.j = null;
        dVar2.h = -2.14748365E9f;
        dVar2.i = 2.14748365E9f;
        invalidateSelf();
    }

    public final void d(Canvas canvas) {
        int i = -1;
        float width;
        float height;
        float min;
        float f;
        float width2;
        float height2;
        float f2;
        if (ScaleType.FIT_XY == this.i) {
            if (this.o != null) {
                Rect bounds = getBounds();
                width = ((float) bounds.width()) / ((float) this.b.j.width());
                height = ((float) bounds.height()) / ((float) this.b.j.height());
                if (this.s) {
                    min = Math.min(width, height);
                    if (min < 1.0f) {
                        f = 1.0f / min;
                        width /= f;
                        height /= f;
                    } else {
                        f = 1.0f;
                    }
                    if (f > 1.0f) {
                        i = canvas.save();
                        width2 = ((float) bounds.width()) / 2.0f;
                        height2 = ((float) bounds.height()) / 2.0f;
                        f2 = width2 * min;
                        min *= height2;
                        canvas.translate(width2 - f2, height2 - min);
                        canvas.scale(f, f, f2, min);
                    }
                }
                this.a.reset();
                this.a.preScale(width, height);
                this.o.g(canvas, this.a, this.p);
                if (i > 0) {
                    canvas.restoreToCount(i);
                }
            }
        } else if (this.o != null) {
            height2 = this.d;
            width = Math.min(((float) canvas.getWidth()) / ((float) this.b.j.width()), ((float) canvas.getHeight()) / ((float) this.b.j.height()));
            if (height2 > width) {
                height2 = this.d / width;
            } else {
                width = height2;
                height2 = 1.0f;
            }
            if (height2 > 1.0f) {
                i = canvas.save();
                width2 = ((float) this.b.j.width()) / 2.0f;
                height = ((float) this.b.j.height()) / 2.0f;
                f2 = width2 * width;
                min = height * width;
                f = this.d;
                canvas.translate((width2 * f) - f2, (f * height) - min);
                canvas.scale(height2, height2, f2, min);
            }
            this.a.reset();
            this.a.preScale(width, width);
            this.o.g(canvas, this.a, this.p);
            if (i > 0) {
                canvas.restoreToCount(i);
            }
        }
    }

    public void draw(Canvas canvas) {
        this.t = false;
        if (this.f) {
            try {
                d(canvas);
            } catch (Throwable unused) {
                Objects.requireNonNull((c.a.a.e0.b) c.a.a.e0.c.a);
            }
        } else {
            d(canvas);
        }
        c.a("Drawable#draw");
    }

    public float e() {
        return this.c.e();
    }

    public float f() {
        return this.c.f();
    }

    public float g() {
        return this.c.d();
    }

    public int getAlpha() {
        return this.p;
    }

    public int getIntrinsicHeight() {
        f fVar = this.b;
        if (fVar == null) {
            return -1;
        }
        return (int) (((float) fVar.j.height()) * this.d);
    }

    public int getIntrinsicWidth() {
        f fVar = this.b;
        if (fVar == null) {
            return -1;
        }
        return (int) (((float) fVar.j.width()) * this.d);
    }

    public int getOpacity() {
        return -3;
    }

    public int h() {
        return this.c.getRepeatCount();
    }

    public boolean i() {
        c.a.a.e0.d dVar = this.c;
        if (dVar == null) {
            return false;
        }
        return dVar.k;
    }

    public void invalidateDrawable(Drawable drawable) {
        Callback callback = getCallback();
        if (callback != null) {
            callback.invalidateDrawable(this);
        }
    }

    public void invalidateSelf() {
        if (!this.t) {
            this.t = true;
            Callback callback = getCallback();
            if (callback != null) {
                callback.invalidateDrawable(this);
            }
        }
    }

    public boolean isRunning() {
        return i();
    }

    public void j() {
        if (this.o == null) {
            this.g.add(new g());
            return;
        }
        if (this.e || h() == 0) {
            c.a.a.e0.d dVar = this.c;
            dVar.k = true;
            boolean g = dVar.g();
            for (AnimatorListener animatorListener : dVar.b) {
                if (VERSION.SDK_INT >= 26) {
                    animatorListener.onAnimationStart(dVar, g);
                } else {
                    animatorListener.onAnimationStart(dVar);
                }
            }
            dVar.j((float) ((int) (dVar.g() ? dVar.e() : dVar.f())));
            dVar.e = 0;
            dVar.g = 0;
            dVar.h();
        }
        if (!this.e) {
            l((int) (this.c.c < 0.0f ? f() : e()));
            this.c.c();
        }
    }

    public void k() {
        if (this.o == null) {
            this.g.add(new h());
            return;
        }
        if (this.e || h() == 0) {
            c.a.a.e0.d dVar = this.c;
            dVar.k = true;
            dVar.h();
            dVar.e = 0;
            if (dVar.g() && dVar.f == dVar.f()) {
                dVar.f = dVar.e();
            } else if (!dVar.g() && dVar.f == dVar.e()) {
                dVar.f = dVar.f();
            }
        }
        if (!this.e) {
            l((int) (this.c.c < 0.0f ? f() : e()));
            this.c.c();
        }
    }

    public void l(int i) {
        if (this.b == null) {
            this.g.add(new c(i));
        } else {
            this.c.j((float) i);
        }
    }

    public void m(int i) {
        if (this.b == null) {
            this.g.add(new k(i));
            return;
        }
        c.a.a.e0.d dVar = this.c;
        dVar.k(dVar.h, ((float) i) + 0.99f);
    }

    public void n(String str) {
        f fVar = this.b;
        if (fVar == null) {
            this.g.add(new n(str));
            return;
        }
        c.a.a.b0.h d = fVar.d(str);
        if (d != null) {
            m((int) (d.b + d.c));
            return;
        }
        throw new IllegalArgumentException(c.b.a.a.a.E("Cannot find marker with name ", str, "."));
    }

    public void o(float f) {
        f fVar = this.b;
        if (fVar == null) {
            this.g.add(new l(f));
        } else {
            m((int) c.a.a.e0.f.e(fVar.k, fVar.l, f));
        }
    }

    public void p(int i, int i2) {
        if (this.b == null) {
            this.g.add(new b(i, i2));
        } else {
            this.c.k((float) i, ((float) i2) + 0.99f);
        }
    }

    public void q(String str) {
        f fVar = this.b;
        if (fVar == null) {
            this.g.add(new a(str));
            return;
        }
        c.a.a.b0.h d = fVar.d(str);
        if (d != null) {
            int i = (int) d.b;
            p(i, ((int) d.c) + i);
            return;
        }
        throw new IllegalArgumentException(c.b.a.a.a.E("Cannot find marker with name ", str, "."));
    }

    public void r(int i) {
        if (this.b == null) {
            this.g.add(new i(i));
            return;
        }
        c.a.a.e0.d dVar = this.c;
        dVar.k((float) i, (float) ((int) dVar.i));
    }

    public void s(String str) {
        f fVar = this.b;
        if (fVar == null) {
            this.g.add(new m(str));
            return;
        }
        c.a.a.b0.h d = fVar.d(str);
        if (d != null) {
            r((int) d.b);
            return;
        }
        throw new IllegalArgumentException(c.b.a.a.a.E("Cannot find marker with name ", str, "."));
    }

    public void scheduleDrawable(Drawable drawable, Runnable runnable, long j) {
        Callback callback = getCallback();
        if (callback != null) {
            callback.scheduleDrawable(this, runnable, j);
        }
    }

    public void setAlpha(int i) {
        this.p = i;
        invalidateSelf();
    }

    public void setColorFilter(ColorFilter colorFilter) {
        c.a.a.e0.c.b("Use addColorFilter instead.");
    }

    public void start() {
        Callback callback = getCallback();
        if ((callback instanceof View) && !((View) callback).isInEditMode()) {
            j();
        }
    }

    public void stop() {
        this.g.clear();
        this.c.c();
    }

    public void t(float f) {
        f fVar = this.b;
        if (fVar == null) {
            this.g.add(new j(f));
        } else {
            r((int) c.a.a.e0.f.e(fVar.k, fVar.l, f));
        }
    }

    public void u(float f) {
        f fVar = this.b;
        if (fVar == null) {
            this.g.add(new d(f));
            return;
        }
        this.c.j(c.a.a.e0.f.e(fVar.k, fVar.l, f));
        c.a("Drawable#setProgress");
    }

    public void unscheduleDrawable(Drawable drawable, Runnable runnable) {
        Callback callback = getCallback();
        if (callback != null) {
            callback.unscheduleDrawable(this, runnable);
        }
    }

    public final void v() {
        f fVar = this.b;
        if (fVar != null) {
            float f = this.d;
            setBounds(0, 0, (int) (((float) fVar.j.width()) * f), (int) (((float) this.b.j.height()) * f));
        }
    }
}
